# Contributor: John Regan <john@jrjrtech.com>
# Maintainer: Laurent Bercot <ska-devel@skarnet.org>
pkgname=s6
pkgver=2.12.0.4
pkgrel=0
pkgdesc="skarnet.org's small & secure supervision software suite."
url=https://skarnet.org/software/s6/
arch="all"
license="ISC"
makedepends="skalibs-dev>=2.14 execline-dev"
depends="s6-ipcserver execline"
options="!check"
subpackages="$pkgname-ipcserver $pkgname-static $pkgname-dev $pkgname-doc $pkgname-openrc"
source="https://skarnet.org/software/s6/s6-$pkgver.tar.gz s6-svscanboot s6.initd"
install="s6.pre-install s6.pre-upgrade"
triggers="s6.trigger=/run/service"

_ipcserver_binaries="bin/s6-ipcserver bin/s6-ipcserver-socketbinder bin/s6-ipcserverd bin/s6-applyuidgid"

build() {
	./configure \
		--enable-shared \
		--enable-static \
		--disable-allstatic \
		--libdir=/usr/lib \
		--libexecdir="/lib/$pkgname" \
		--with-dynlib=/lib
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D "$srcdir/s6-svscanboot" "$pkgdir/lib/s6/s6-svscanboot"
	install -D "$srcdir/s6.initd" "$pkgdir/etc/init.d/s6"
}

doc() {
	default_doc
	mkdir -p "$subpkgdir/usr/share/doc"
	cp -a "$builddir/doc" "$subpkgdir/usr/share/doc/$pkgname"
}

ipcserver() {
	depends=""
	amove $_ipcserver_binaries
}

sha512sums="
dfdb9c0189177762a89d1f47e1d6b0a82bba5554baef4fa899b1c0a85c192d5e1dac2b929173d750df3707f0d699b28591f1eab3e63b8791e4a51af1c65e3e56  s6-2.12.0.4.tar.gz
9104c3d18a36c8aaa51da553cc045881438ad55f251ba8155e90143cb9a0d3723d22cbbaeb0388e9bc162bda89d8028a6202b0b7ceca01c8d1f197bb990d128d  s6-svscanboot
d4ff33bbd674160f3d47ed8d566fe756ee5a54e1e8febd7d873f5f5158d1c4eeac1ddf460fbc6f23b75a8ee2d007117c3ababa6311ae9dcc5ad087dc4a154eee  s6.initd
"
